﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.SessionState;
/// <summary>
///frontCurrentTea 的摘要说明
/// </summary>
public static class frontCurrentTea
{

    //
    //TODO: 在此处添加构造函数逻辑
    //
    /// <summary>
    /// 得到教师信息ID
    /// </summary>
    /// <returns></returns>
    public static int GetUserID()
    {

        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session

        if (tempSession["TeacherID"] == null)
        {
            //return 3;
            return -1;

            // return -1;//throw new ApplicationException("出错了!未登录，或session已经过期!");


        }
        else
        {
            return Convert.ToInt32(tempSession["TeacherID"]);
        }


    }
    /// <summary>
    /// 登录名，即教师工号
    /// </summary>
    /// <returns></returns>
    public static string GetNo()
    {

        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session

        if (tempSession["TeaNo"] == null)
        {
            return "";
            // return String.Empty ;// throw new ApplicationException("出错了!未登录，或session已经过期!");

        }
        else
        {
            return (string)tempSession["TeaNo"];
        }
    }



    /// <summary>
    /// 取当前用户的用户名
    /// </summary>
    /// <returns></returns>
    public static string GetUserName()
    {

        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session

        if (tempSession["TeaName"] == null)
        {
            return "";
            // return String.Empty ;// throw new ApplicationException("出错了!未登录，或session已经过期!");
        }
        else
        {
            return (string)tempSession["TeaName"];
        }

    }


  

    /// <summary>
    /// 得到当前的老师学院代码
    /// </summary>
    /// <returns></returns>
    public static int GetPartCode()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session
        if (tempSession["TeaPartCode"] == null)
        {
            return -1;
        }
        else
        {
            return Convert.ToInt32(tempSession["TeaPartCode"]);
        }

    }


    /// <summary>
    /// 清除Session
    /// </summary>
    public static void ClearSession()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        tempSession.Clear();
    }



    #region  yzp


    /// <summary>
    /// 得到当前的老师课程代码
    /// </summary>
    /// <returns></returns>
    public static int GetCurrentCourseID()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session
        if (tempSession["CurrentCourseID"] == null)
        {
            return -1;
        }
        else
        {
            return Convert.ToInt32(tempSession["CurrentCourseID"]);
        }

    }

    /// <summary>
    /// 设置到当前的课程ID
    /// </summary>
    /// <returns></returns>
    public static void SetCurrentCourseID(int CurrentCourseID)
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

        tempSession["CurrentCourseID"] = CurrentCourseID;


    }

    /// <summary>
    /// 设置到当前的试题ID
    /// </summary>
    /// <returns></returns>
    public static void SetCurrentQuestionID(long QuestionID)
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

        tempSession["CurrentQuestionID"] = QuestionID;


    }
    /// <summary>
    /// 设置到当前的试题ID
    /// </summary>
    /// <returns></returns>
    public static long GetCurrentQuestionID()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session
        if (tempSession["CurrentQuestionID"] == null)
        {
            return -1;
        }
        else
        {
            return Convert.ToInt64(tempSession["CurrentQuestionID"]);
        }

    }


    /// <summary>
    /// 设置到当前的试题类型
    /// </summary>
    /// <returns></returns>
    public static void SetCurrentQuestionKind(int QuestionKind)
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

        tempSession["CurrentQuestionKind"] = QuestionKind;


    }
    /// <summary>
    /// 设置到当前的试题ID
    /// </summary>
    /// <returns></returns>
    public static int GetCurrentQuestionKind()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session
        if (tempSession["CurrentQuestionKind"] == null)
        {
            return -1;
        }
        else
        {
            return Convert.ToInt32(tempSession["CurrentQuestionKind"]);
        }

    }

    /// <summary>
    /// 设置当前试卷的ID
    /// </summary>
    /// <returns></returns>
    public static void SetCurrentPaperID(int PaperID)
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

        tempSession["CurrentPaperID"] = PaperID;


    }
    /// <summary>
    /// 获取当前试卷的ID
    /// </summary>
    /// <returns></returns>
    public static int GetCurrentPaperID()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        if (tempSession["CurrentPaperID"] == null)
        {
            return -1;
        }
        else
        {
            return Convert.ToInt32(tempSession["CurrentPaperID"]);
        }

    }

    /// <summary>
    /// 取得当前用户类型，0学生，1教师，2管理员，3所有用户
    /// </summary>
    /// <returns></returns>
    public static string GetUserType()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        if (!string.IsNullOrEmpty(tempSession["UserType"].ToString()))
        {
            string UserType = tempSession["UserType"].ToString();
            return UserType;
        }
        return "";
    }


    /// <summary>
    /// 设置到当前的StrategyID;
    /// </summary>
    /// <returns></returns>
    public static void SetCurrentStrategyID(int StrategyID)
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

        tempSession["CurrentStrategyID"] = StrategyID;


    }
    /// <summary>
    /// 设置到当前的StrategyID
    /// </summary>
    /// <returns></returns>
    public static long GetCurrentStrategyID()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session
        if (tempSession["CurrentStrategyID"] == null)
        {
            return -1;
        }
        else
        {
            return Convert.ToInt32(tempSession["CurrentStrategyID"]);
        }

    }



    /// <summary>
    /// 设置到当前的DictID;  添加于1.02
    /// </summary>
    /// <returns></returns>
    public static void SetCurrentDictID(int DictID)
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

        tempSession["CurrentDictID"] = DictID;


    }
    /// <summary>
    /// 设置到当前的DictID  添加于1.02
    /// </summary>
    /// <returns></returns>
    public static long GetCurrentDictID()
    {
        HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
        //此处应当使用session
        if (tempSession["CurrentDictID"] == null)
        {
            return -1;
        }
        else
        {
            return Convert.ToInt32(tempSession["CurrentDictID"]);
        }

    }


    #endregion yzp
}
